// AUTO GENERATED CODE!
// CODE GENERATOR WILL NOT PRESERVE MANUAL CHANGES TO THIS CODE!
// 

// MIT License (MIT)
// 
// Copyright (c) 2014 K Ercan Turkarslan
// 
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// 
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
// 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
// 


using System;

namespace Mios.Generated.ServiceFiles
{
    // Generated from S_JobHandler1.xml
    
    public class JobHandler1Service : MiosService
    {
        #region NumActiveJobs : Byte;
        private Byte? _mNumActiveJobs;
        
        public Byte NumActiveJobs
        {
            get
            {
                return _mNumActiveJobs ?? GetNumActiveJobs();
            }
        }
        
        #region Action SetNumActiveJobs(Byte newNumActiveJobs) : String;
        public String SetNumActiveJobs(Byte newNumActiveJobs)
        {
            if(newNumActiveJobs > 100)
                throw new ArgumentOutOfRangeException("newNumActiveJobs");
            
            return Engine.Luup_CallAction(base.DeviceId, base.ServiceId, "SetNumActiveJobs",
                String.Format("newNumActiveJobs={0}", ToLuup(_mNumActiveJobs = newNumActiveJobs)));
        }
        #endregion Action SetNumActiveJobs
        
        // WARNING: Service Description File does not contain any Get Action with a
        // argument related to this State Variable.
        // 
        // This may be due to a typo while defining the Get Action or state variable.
        // This may also be intentional. Code generator assumes this was a mistake and
        // generates this Get Action.
        
        #region Action GetNumActiveJobs() : Byte;
        public Byte GetNumActiveJobs()
        {
            _mNumActiveJobs = FromLuupByte(Engine.Luup_VariableGet(base.DeviceId, base.ServiceId, "NumActiveJobs"));
            
            return _mNumActiveJobs.Value;
        }
        #endregion Action GetNumActiveJobs
        
        #endregion
        
        #region LoadLevelTarget : String;
        // WARNING: This state variable was not defined in the Service Description file.
        // However it was referenced by one or more Actions as their related state variable.
        // Or it was returned by Vera in USER_DATA xml.
        // This may be due to a typo in RelatedStateVariable definition or missing State Variable.
        
        private String _mLoadLevelTarget;
        
        public String LoadLevelTarget
        {
            get
            {
                return _mLoadLevelTarget ?? GetLoadLevelTarget();
            }
        }
        
        #region Action SetLoadLevelTarget(String newLoadlevelTarget) : String;
        public String SetLoadLevelTarget(String newLoadlevelTarget)
        {
            if (String.IsNullOrEmpty(newLoadlevelTarget))
                throw new ArgumentNullException("newLoadlevelTarget");
            
            return Engine.Luup_CallAction(base.DeviceId, base.ServiceId, "SetLoadLevelTarget",
                String.Format("newLoadlevelTarget={0}", ToLuup(_mLoadLevelTarget = newLoadlevelTarget)));
        }
        #endregion Action SetLoadLevelTarget
        
        // WARNING: Service Description File does not contain any Get Action with a
        // argument related to this State Variable.
        // 
        // This may be due to a typo while defining the Get Action or state variable.
        // This may also be intentional. Code generator assumes this was a mistake and
        // generates this Get Action.
        
        #region Action GetLoadLevelTarget() : String;
        public String GetLoadLevelTarget()
        {
            _mLoadLevelTarget = FromLuupString(Engine.Luup_VariableGet(base.DeviceId, base.ServiceId, "LoadLevelTarget"));
            
            return _mLoadLevelTarget;
        }
        #endregion Action GetLoadLevelTarget
        
        #endregion
        
        
        #region Method SetVariable(String name, String value) : Boolean;
        internal override Boolean SetVariable(String name, String value)
        {
            switch(name)
            {
                case "LoadLevelTarget":
                    _mLoadLevelTarget = FromLuupString(value); return true;
                case "NumActiveJobs":
                    _mNumActiveJobs = FromLuupByte(value); return true;
                default:
                    return false;
            }
        }
        #endregion Method SetVariable
        
        public JobHandler1Service(MiosEngine engine, UInt32 deviceId, String serviceId)
            : base(engine, deviceId, serviceId)
        {
            
        } //End Constructor
    } //End of class
} //End of Namespace

